<?php
/**
 * Copyright 2011  SURFfoundation
 * 
 * This file is part of ESCAPE.
 * 
 * ESCAPE is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * ESCAPE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with ESCAPE.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * For more information:
 * http://escapesurf.wordpress.com/
 * http://www.surffoundation.nl/
 * 
 * Contact: d.vierkant@utwente.nl
 * 
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3
 */
?>
<?php
/**
 * Result entry
 * 
 * Represents the data and score of a matched entity.
 */
class entityresolution_ResultEntry
{
	/**
	 * Subject URI.
	 * @var string
	 */
	protected $subjectUri;
	
	/**
	 * Data.
	 * @var simplerdf_RdfDocument
	 */
	protected $data;
	
	/**
	 * Difference score.
	 * @var float
	 */
	protected $score;

	/**
	 * Get the subject URI.
	 * @return string subject URI
	 */
	public function getSubjectUri()
	{
		return $this->subjectUri;
	}
	
	/**
	 * Set the subject URI.
	 * @param string $subjectUri subject URI
	 */
	public function setSubjectUri($subjectUri)
	{
		$this->subjectUri = $subjectUri;
	}
	
	/**
	 * Get the data.
	 * @return simplerdf_RdfDocument data
	 */
	public function getData()
	{
		return $this->data;
	}
	
	/**
	 * Set the data.
	 * @param simplerdf_RdfDocument $data data
	 */
	public function setData($data)
	{
		$this->data = $data;
	}
	
	/**
	 * Get the difference score.
	 * @return float difference score
	 */
	public function getScore()
	{
		return $this->score;
	}
	
	/**
	 * Set the difference score.
	 * @param float $score difference score
	 */
	public function setScore($score)
	{
		$this->score = $score;
	}
	
	/**
	 * Compare two result entries by score, used for ordering result sets using uasort().
	 * @param entityresolution_ResultEntry $entryA entry A
	 * @param entityresolution_ResultEntry $entryB entry B
	 */
	public static function compareScores($entryA, $entryB)
	{
		if ($entryA->getScore() == $entryB->getScore()) {
			return 0;
		}
		return ($entryA->getScore() < $entryB->getScore()) ? -1 : 1;
	}
}